﻿@{
    ViewBag.Title = "Index";
}


@using (Html.BeginForm("Index", "YahooFinance", FormMethod.Post, new { id = "stockSearch" }))
{ 
    
	<div class="current-stocks">
        @Html.Label("SearchSymbols", "Enter stock comma-seperated symbols")
        @Html.TextBox("SearchSymbols")
        <input type="submit" class="current-stocks-btn" value="Search" />	
	</div>            
        
}

@if(IsPost){
    
    if(Model.Count > 0)
    {
        foreach (var currentStock in Model)
        {
     
            <h3>@currentStock.Name Current Performance</h3>
            <table class="portfolio-table">
                <tr>
                    <th>
                        Current Change:
                    </th>
                    <td>
                        @currentStock.Change
                    </td>
                </tr>
                <tr>
                    <th>
                        Latest Open:
                    </th>
                    <td>
                        @currentStock.Open
                    </td>
                </tr>
                <tr>
                    <th>
                        Previous Close:
                    </th>
                    <td>
                       @currentStock.PreviousClose
                    </td>
                </tr>
                <tr>
                    <th>
                        Bid:
                    </th>
                    <td>
                       @currentStock.Bid
                    </td>
                </tr>
                <tr>
                    <th>
                        Ask:
                    </th>
                    <td>
                        @currentStock.Ask
                    </td>
                </tr>
                <tr>
                    <th>
                        Volume:
                    </th>
                    <td>
                        @currentStock.Volume
                    </td>
                </tr>
                <tr>
                    <th>
                        EPS:
                    </th>
                    <td>
                        @currentStock.EPS
                    </td>
                </tr>
            </table>
            <h3>@currentStock.Name Historical Performance</h3>
            <div id="@(currentStock.Symbol)chart" style="min-width:500px"></div>
            <script>chartHistoricalData('YahooFinance', '@(currentStock.Symbol)', 'Multiple');</script>
        }
    }    
    else
    {
        <p>Invalid Symbol String.  Please enter comma-seperated stock symbols (e.g. MSFT or GE, GOOG) </p>
    }
    
}